home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-01-18 | 6.4 KB | 171 lines | [TEXT/ToyS] |
- -- These properties set the vertical & horizontal offsets to use for each
- -- sucessive level of windows.
- property pVerticalOffset : 15 -- how much to offset the windows down for each level
- property pHorizontalOffset : 0 -- how much to offset the windows right for each level
- property pStaggerBottoms : false
-
- -- These properties set the top and bottom of the first window of the item dropped on the script.
- -- The difference of these two values defines the height of all windows.
- property pWindTopStart : 40 -- the top of the drive window
- property pWindBotStart : 650 -- the bottom of the first winow
-
- -- These properties set the left and right of the first window of the item dropped on the script.
- -- The difference of these two values defines the width of all windows.
- property pWindLeftStart : 2
- property pWindRightStart : 380
-
- -- a list of properties for setting the view of a window
- property pViewSettingList : ¬
- {pBySmallIcon:0, pByIcon:1, pByName:2, pBySize:4 ¬
- , pByKind:5, pByLabel:7, pByLastModified:3, pByVersion:8, pByComment:6}
- property pViewSettingMenu : [0, 1, 2, 4, 5, 7, 3, 8, 6]
-
- -- This property controls the type of view you want ALL windows to have
- property pViewType : pByName of pViewSettingList
-
- (******************************)
-
- on run
- set theItem to choose folder with prompt "Locate disk to process."
- open {theItem} -- as a list
- end run
-
- (******************************)
-
- on open theItems -- the Finder always provides us with a list, even for a single item
- set viewItem to 1
- repeat with i from 1 to pViewSettingMenu's length
- if pViewSettingMenu's item i = pViewType then
- set viewItem to i
- exit repeat
- end if
- end repeat
-
- set dSetFolderWindows to {size:[310, 280], name:"Set Folder Windows", style:movable dialog, contents:[¬
- {class:push button, bounds:[240, 250, 300, 270], name:"OK"}, ¬
- {class:push button, bounds:[165, 250, 225, 270], name:"Cancel"}, ¬
- {class:text field, bounds:[98, 40, 148, 56], value:pWindLeftStart}, ¬
- {class:text field, bounds:[237, 40, 287, 56], value:pWindTopStart}, ¬
- {class:text field, bounds:[98, 66, 148, 82], value:pWindBotStart}, ¬
- {class:text field, bounds:[237, 66, 287, 82], value:pWindRightStart}, ¬
- {class:static text, bounds:[20, 40, 90, 56], contents:"Left"}, ¬
- {class:static text, bounds:[176, 40, 233, 56], contents:"Top"}, ¬
- {class:static text, bounds:[20, 66, 90, 82], contents:"Bottom"}, ¬
- {class:static text, bounds:[176, 66, 233, 82], contents:"Right"}, ¬
- {class:group box, bounds:[10, 10, 300, 98], name:"First Window"}, ¬
- {class:text field, bounds:[98, 140, 148, 156], value:pHorizontalOffset}, ¬
- {class:text field, bounds:[237, 140, 287, 156], value:pVerticalOffset}, ¬
- {class:static text, bounds:[20, 140, 90, 156], contents:"Horizontal"}, ¬
- {class:static text, bounds:[176, 140, 233, 156], contents:"Vertical"}, ¬
- {class:group box, bounds:[10, 110, 300, 200], name:"Windows Offset"}, ¬
- {class:check box, bounds:[20, 173, 180, 191], name:"Stagger Bottoms", value:pStaggerBottoms}, ¬
- {class:pop up, bounds:[10, 210, 190, 230], name:"View", value:viewItem, contents:["by Small Icon", "by Icon", "by Name", "by Size", "by Size", "by Kind", "by Label", "by Last Modified", "by Version", "by Comment"]} ¬
- ] ¬
- }
-
- set dVals to dd auto dialog dSetFolderWindows with grayscale
- set [_, cancel, pWindLeftStart, pWindTopStart, pWindBotStart, pWindRightStart, _, _, _, _, _ ¬
- , pHorizontalOffset, pVerticalOffset, _, _, _, pStaggerBottoms, viewItem, _] to dVals
- if cancel then return
- set pViewType to pViewSettingMenu's item viewItem
-
- set startTime to time of (current date)
-
- repeat with anItem in theItems
- tell application "Finder" to set itemKind to kind of anItem
- if itemKind is in {"folder", "disk"} then
- HProcessContainer for contents of anItem
- end if
- end repeat
-
- set endTime to time of (current date)
- display dialog "Execution time: " & (endTime - startTime)
- end open
-
- (******************************)
-
- on HProcessContainer for theContainer
- set folderDepth to 0
-
- set windowBounds to HCalculateWindowBounds for folderDepth
-
- ignoring application responses
- tell application "Finder"
- open theContainer -- we've got to open the window before we can set it's values
-
- set bounds of window of theContainer to windowBounds
- set view of window of theContainer to pViewType
-
- -- ensures that if the windows are set to a list view, nested folders are not open
- if pViewType is greater than 1 then
- set expanded of folders of theContainer to false
- end if
-
- close theContainer -- done with the window, close it
- end tell
- end ignoring
-
- HProcessContainedFolders for theContainer at folderDepth
- end HProcessContainer
-
- (******************************)
-
- on HProcessContainedFolders for theContainer at folderDepth
- set folderDepth to folderDepth + 1
- set windowBounds to HCalculateWindowBounds for folderDepth
-
- -- process all the folder inside this container as a group for speed
- -- since Finder operation return a list of the objects they operated on, we can save an call here
- tell application "Finder" to set folderList to open folders in theContainer
-
- if (count of folderList) > 0 then
- tell application "Finder"
- ignoring application responses
- set bounds of window of folders in theContainer to windowBounds
- set view of window of folders in theContainer to pViewType
-
- -- ensure that if the windows are set to a list view, nested folders are not open
- if pViewType > 1 then
- set expanded of folders of window of folders in theContainer to false
- end if
-
- close windows -- folders in theContainer
- end ignoring
- end tell
-
- repeat with aFolder in folderList
- HProcessContainedFolders for aFolder at folderDepth
- end repeat
- end if
- end HProcessContainedFolders
-
- (******************************)
-
- to HCalculateWindowBounds for folderDepth
- -- Calculate the values to be used for window bounds
- if pVerticalOffset = 0 then
- set windTop to pWindTopStart
- set windBot to pWindBotStart
- else
- set vertOffset to folderDepth * pVerticalOffset
- set windTop to pWindTopStart + vertOffset
-
- if pStaggerBottoms then
- set windBot to pWindBotStart + vertOffset
- else
- set windBot to pWindBotStart
- end if
- end if
-
- if pHorizontalOffset = 0 then
- set windLeft to pWindLeftStart
- set windRight to pWindRightStart
- else
- set horizOffset to folderDepth * pHorizontalOffset
- set windLeft to pWindLeftStart + horizOffset
- set windRight to pWindRightStart + horizOffset
- end if
-
- return {windLeft, windTop, windRight, windBot}
- end HCalculateWindowBounds
-